package c.c.b.a.b;

import java.io.Closeable;

/* compiled from: Response */
public final class c implements Closeable {
    public final c0 a;
    public final a0 b;
    public final int c;
    public final String d;
    public final u e;
    public final v f;
    public final e g;
    public final c h;
    public final c i;
    public final c j;
    public final long k;
    public final long l;
    public volatile i m;

    /* compiled from: Response */
    public static class a {
        public c0 a;
        public a0 b;
        public int c;
        public String d;
        public u e;
        public c.c.b.a.b.v.a f;
        public e g;
        public c h;
        public c i;
        public c j;
        public long k;
        public long l;

        public a() {
            this.c = -1;
            this.f = new c.c.b.a.b.v.a();
        }

        public a a(v vVar) {
            this.f = vVar.e();
            return this;
        }

        public c b() {
            if (this.a == null) {
                throw new IllegalStateException("request == null");
            } else if (this.b == null) {
                throw new IllegalStateException("protocol == null");
            } else if (this.c < 0) {
                StringBuilder g = c.b.a.a.a.g("code < 0: ");
                g.append(this.c);
                throw new IllegalStateException(g.toString());
            } else if (this.d != null) {
                return new c(this);
            } else {
                throw new IllegalStateException("message == null");
            }
        }

        public final void c(String str, c cVar) {
            if (cVar.g != null) {
                throw new IllegalArgumentException(c.b.a.a.a.D(str, ".body != null"));
            } else if (cVar.h != null) {
                throw new IllegalArgumentException(c.b.a.a.a.D(str, ".networkResponse != null"));
            } else if (cVar.i != null) {
                throw new IllegalArgumentException(c.b.a.a.a.D(str, ".cacheResponse != null"));
            } else if (cVar.j != null) {
                throw new IllegalArgumentException(c.b.a.a.a.D(str, ".priorResponse != null"));
            }
        }

        public a d(c cVar) {
            if (cVar != null) {
                c("cacheResponse", cVar);
            }
            this.i = cVar;
            return this;
        }

        public a(c cVar) {
            this.c = -1;
            this.a = cVar.a;
            this.b = cVar.b;
            this.c = cVar.c;
            this.d = cVar.d;
            this.e = cVar.e;
            this.f = cVar.f.e();
            this.g = cVar.g;
            this.h = cVar.h;
            this.i = cVar.i;
            this.j = cVar.j;
            this.k = cVar.k;
            this.l = cVar.l;
        }
    }

    public c(a aVar) {
        this.a = aVar.a;
        this.b = aVar.b;
        this.c = aVar.c;
        this.d = aVar.d;
        this.e = aVar.e;
        this.f = new v(aVar.f);
        this.g = aVar.g;
        this.h = aVar.h;
        this.i = aVar.i;
        this.j = aVar.j;
        this.k = aVar.k;
        this.l = aVar.l;
    }

    public void close() {
        e eVar = this.g;
        if (eVar != null) {
            eVar.close();
            return;
        }
        throw new IllegalStateException("response is not eligible for a body and must not be closed");
    }

    public i n() {
        i iVar = this.m;
        if (iVar != null) {
            return iVar;
        }
        iVar = i.a(this.f);
        this.m = iVar;
        return iVar;
    }

    public String toString() {
        StringBuilder g = c.b.a.a.a.g("Response{protocol=");
        g.append(this.b);
        g.append(", code=");
        g.append(this.c);
        g.append(", message=");
        g.append(this.d);
        g.append(", url=");
        g.append(this.a.a);
        g.append('}');
        return g.toString();
    }
}
